var WPC={};
function AssertException(_1){
this.message=_1;
}
AssertException.prototype.toString=function(){
return "AssertException: "+this.message;
};
function assert(_2,_3){
if(!_2){
throw new AssertException(_3);
}
}
if(!window.console){
console={log:function(){
}};
}
function log(o){
if(top.console&&top.console.log){
top.console.log(o);
}else{
if(top.jash){
top.jash.print(o);
}
}
}
function acquire(_5,_6,_7){
var r_=Math.random();
var _9=function(){
var _a=WPC.cookie.get(_5);
if(_a==r_){
_6&&_6();
}else{
_7&&_7();
}
};
WPC.cookie.set(_5,r_);
setTimeout(_9,40);
}
(function(ns){
var ua=navigator.userAgent.toLowerCase();
var _d=document.domain.substring(document.domain.indexOf(".")+1);
function isArray(_e){
return Object.prototype.toString.call(_e)==="[object Array]";
}
function textNodeValue(_f){
var c=_f.firstChild;
while(c){
if(!c.isElementContentWhitespace){
return c.textContent;
}
c=c.nextSibling;
}
return null;
}
ns.startXnclient=function(){
var a;
try{
a=new ActiveXObject("xntalk.Application.2");
}
catch(e){
return false;
}
if(!a){
return false;
}
var res;
try{
res=a.login();
}
catch(e){
return false;
}
if(res==1){
return false;
}
return true;
};
ns.startXnService=function(){
var ret;
var svr=new ActiveXObject("renren.Renren.1");
ret=svr.StartUp("xntalk");
if(ret==1){
return false;
}
return true;
};
ns.getLoginUin=function(){
var uin=ns.cookie.get("id");
if(!uin){
uin=ns.cookie.get("hostid");
}
if(!uin){
uin=ns.cookie.get("userid");
}
return uin;
};
ns.xmlEncode=function(str){
str=str.replace(/&/g,"&amp;");
str=str.replace(/</g,"&lt;");
str=str.replace(/>/g,"&gt;");
str=str.replace(/'/g,"&apos;");
str=str.replace(/\"/g,"&quot;");
return str;
};
ns.countStr=function(b,a){
try{
var tmp=b.split(a);
}
catch(e){
return 0;
}
return (tmp.length-1);
};
ns.isInArray=function(v,ary){
for(var i=0;i<ary.length;i++){
if(ary[i]==v){
return true;
}
}
return false;
};
ns.distinct=function(a){
var ret=[];
var b={};
for(var i=0;i<a.length;i++){
b[a[i]]=1;
}
for(key in b){
ret.push(key);
}
return ret;
};
ns.parseUserInfo=function(str){
var _22=/(\d+)@([^\/]+)\/(.*)/;
return _22.exec(str);
};
ns.logger={beatNum:0,heartBeat:function(){
var _23=this;
this.timer=setTimeout(function(){
_23.beatNum++;
clearTimeout(_23.timer);
ns.PersistMgr.report("heartBeat");
_23.heartBeat();
},1000*30);
},stopBeat:function(){
clearTimeout(this.timer);
return this.beatNum;
}};
ns.browser={isFirefox:/gecko/.test(ua)&&/rv/.test(ua),isOpera:/opera/.test(ua),isChrome:/chrome/.test(ua),isWebkit:/webkit/.test(ua)&&!/opera/.test(ua)&&!/chrome/.test(ua),isIE:/msie/.test(ua)&&!/opera/.test(ua),browserOK:false};
ns.cookie={get:function(_24){
var _25=document.cookie.match("(^|;) ?"+_24+"=([^;]*)(;|$)");
if(_25){
return decodeURIComponent(_25[2]);
}
return null;
},set:function(_26,_27,_28){
var s=_26+"="+encodeURIComponent(_27);
if(_28){
_28=_28*1000*60*60*24;
var _2a=new Date((new Date()).getTime()+_28);
s+=";expires="+_2a.toGMTString();
}
document.cookie=s;
}};
var ck=ns.cookie;
ns.json={parse:function(str){
return eval("("+str+")");
}};
ns.event={addEvent:function(obj,_2e,fn){
if(!obj._listeners){
obj._listeners={};
}
if(!obj._listeners[_2e]){
obj._listeners[_2e]=[];
}
obj._listeners[_2e].push(fn);
return obj;
},removeEvent:function(obj,_31,fn){
if(!obj._listeners||!obj._listeners[_31]){
assert(false,"remove an event not added");
return;
}
for(var i=0;i<obj._listeners[_31].length;++i){
if(obj._listeners[_31][i]==fn){
var _34=obj._listeners[_31].splice(i,1);
assert(_34[0]==fn,"remove not correct");
}
}
},fireEvent:function(obj,_36,_37){
if(!obj._listeners){
return null;
}
if(!obj._listeners[_36]||!(obj._listeners[_36].length)){
return null;
}
var _38=obj._listeners[_36];
if(!_38){
return null;
}
for(var i=0;i<_38.length;i++){
try{
_38[i].apply(obj,_37);
}
catch(e){
}
}
return obj;
},enableCustomEvent:function(obj){
var _3b=this;
obj.addEvent=function(_3c,fn){
_3b.addEvent(obj,_3c,fn);
};
obj.removeEvent=function(_3e,fn){
_3b.removeEvent(obj,_3e,fn);
};
obj.fireEvent=function(_40){
var _41=Array.prototype.slice.call(arguments,1,arguments.length);
_3b.fireEvent(obj,_40,_41);
};
}};
ns.net={ajax:function(obj){
var xhr=ns.net.getXhr();
xhr.open(obj.method||"get",obj.url,true);
xhr.onreadystatechange=function(){
if(xhr.readyState==4){
if(xhr.status>=200&&xhr.status<300){
if(obj.onSuccess){
obj.onSuccess(xhr);
}
}else{
if(obj.onError){
obj.onError(xhr);
}
}
}
};
xhr.send(obj.data);
return xhr;
},getXhr:function(){
try{
return new XMLHttpRequest();
}
catch(e){
}
try{
return new ActiveXObject("microsoft.xmlhttp");
}
catch(e){
}
try{
return new ActiveXObject("msxml2.xmlhttp");
}
catch(e){
}
return null;
}};
ns.xml={extractMessage:function(_44){
var t=_44.replace(/<title>/i,"<title><![CDATA[");
_44=t.replace(/<\/title>/i,"]]></title>");
t=_44.replace(/<body>/i,"<body><![CDATA[");
_44=t.replace(/<\/body>/i,"]]></body>");
var doc,res=[];
if(window.ActiveXObject){
doc=new ActiveXObject("Microsoft.XMLDOM");
doc.async=false;
doc.loadXML(_44);
if(0!=doc.parseError.errorCode){
return res;
}
var _48=doc.getElementsByTagName("message");
for(var i=0;i<_48.length;++i){
var n=_48[i];
if(n.attributes){
var m={};
m.type=n.getAttribute("type");
m.msg_id=n.getAttribute("id");
if(m.type=="chat"){
m.from=n.getAttribute("from");
m.to=n.getAttribute("to");
m.fname=n.getAttribute("fname");
if(n.firstChild&&n.firstChild.firstChild){
m.msg_content=n.firstChild.firstChild.data;
}
}else{
if(m.type=="notify"||m.type=="notify2"){
m.touin=ns.getLoginUin();
for(var j=0;j<n.childNodes.length;j++){
if(n.childNodes[j].tagName=="subject"){
m.title=n.childNodes[j].childNodes[0].data;
}else{
if(n.childNodes[j].tagName=="body"){
m.content=n.childNodes[j].childNodes[0].data;
}
}
}
}else{
m.from=n.getAttribute("from");
m.to=n.getAttribute("to");
m.content=n.childNodes[0].childNodes[0].data;
}
}
}
res.push(m);
}
}else{
var _4d=new DOMParser();
doc=_4d.parseFromString(_44,"text/xml");
var _4e=doc.documentElement;
var cnt=_4e.childNodes.length;
for(var i=0;i<cnt;++i){
var n=_4e.childNodes[i];
if(n.hasAttributes()){
var m={};
m.type=n.getAttribute("type");
m.msg_id=n.getAttribute("id");
if(m.type=="chat"){
m.from=n.getAttribute("from");
m.to=n.getAttribute("to");
m.fname=n.getAttribute("fname");
if(n.childNodes){
m.msg_content=textNodeValue(n);
}
}else{
if(m.type=="notify"||m.type=="notify2"){
m.touin=ns.getLoginUin();
for(var j=0;j<n.childNodes.length;j++){
if(n.childNodes[j].tagName=="subject"){
m.title=n.childNodes[j].childNodes[0].nodeValue;
}else{
if(n.childNodes[j].tagName=="body"){
m.content=n.childNodes[j].childNodes[0].nodeValue;
}
}
}
}else{
m.from=n.getAttribute("from");
m.to=n.getAttribute("to");
m.content=n.childNodes[0].childNodes[0].nodeValue;
}
}
res.push(m);
}
}
}
return res;
}};
ns.sound={soundLoadCnt:0,init:function(){
this.loadSound();
},loadSound:function(){
var _50="http://wpi."+_d+"/wtalk/wpsound.swf";
var _51="<object width=\"10\" height=\"10\" id=\"webpagersound\" type=\"application/x-shockwave-flash\" data=\""+_50+"\">"+"<param name=\"allowScriptAccess\" value=\"sameDomain\" />"+"<param name=\"movie\" value=\"wpsound.swf\" />"+"<param name=\"scale\" value=\"noscale\" />"+"<param name=\"salign\" value=\"lt\" />"+"</object>";
var sp=document.createElement("div");
sp.innerHTML=_51;
document.body.appendChild(sp);
},playSound:function(_53){
var _54=this;
if(!ns.Profile.isPlaySound()){
return;
}
var snd=document.getElementById("webpagersound");
if(!snd){
if(++this.soundLoadCnt<20){
if(this.soundLoadCnt==1){
this.loadSound();
}
setTimeout(function(){
_54.playSound(_53);
},200);
}
return;
}
try{
if(_53=="notify"){
snd.playNotifySound();
}else{
snd.playMessageSound();
}
}
catch(e){
}
}};
ns.seqq={seqn:40,SEQ_EXPIRE_DAYS:10*365,init:function(){
this.seqn=ck.get("wpseqn")||this.seqn;
},getMsgSeq:function(m){
var n=parseInt(ck.get(m||"wpseq"));
if(isNaN(n)){
return -1;
}
return n>=0?n:0;
},setMsgSeq:function(seq,m){
ck.set(m||"wpseq",seq,this.SEQ_EXPIRE_DAYS);
},getNextSeq:function(_5a){
var _5b=this.getMsgSeq()+1;
this.setMsgSeq(_5b);
if(_5a&&_5a>this.seqn){
this.seqn=_5a;
this.setSeqn(this.seqn);
}
return "s"+_5b%this.seqn;
},setSeqn:function(num){
ck.set("wpseqn",num);
}};
ns.seqq.init();
var _5d=1;
var _5e=2;
var _5f=4;
var _60=8;
ns.Profile={expire:10*365,setting:27,init:function(){
this.load();
},load:function(){
var v=ns.cookie.get("wpsetting");
if(v!=null){
this.setting=parseInt(v);
}
return true;
},isUseIm:function(){
this.load();
return this.setting&_5d;
},isPlaySound:function(){
return this.setting&_5e;
},isStoreHistory:function(){
return this.setting&_60;
},setUseIm:function(b,_63){
if(b){
this.setting|=_5d;
}else{
this.setting&=~_5d;
}
if(_63){
ck.set("wpsetting",this.setting,this.expire);
this.fireEvent("profile_useIM_switch",b?"1":"0");
}
},setPlaySound:function(b,_65){
if(b){
this.setting|=_5e;
}else{
this.setting&=~_5e;
}
if(_65){
ck.set("wpsetting",this.setting,this.expire);
this.fireEvent("profile_sound_switch",b?"1":"0");
}
},setStoreHistory:function(b,_67){
if(b){
this.setting|=_60;
}else{
this.setting&=~_60;
}
if(_67){
ck.set("wpsetting",this.setting,this.expire);
this.fireEvent("profile_setHistory_switch",b?"1":"0");
}
}};
ns.event.enableCustomEvent(ns.Profile);
ns.Profile.init();
})(WPC);
(function(ns){
ns.PersistMgr={write_seq:0,qLen:10,MONIT_INTERV:513,_storage:null,lastModify:{lastKeys:"",keys:[]},lastModKeys:[],init:function(){
var ok=this.initStorage();
if(!ok){
return ok;
}
var obj=this.getLastMod();
this.timestamp=obj.timestamp;
var lm=this.lastModify;
lm.timestamp=this.timestamp;
lm.keys=obj.keysAry;
lm.lastKeys=obj.keys;
this.storageMonit();
return ok;
},initStorage:function(){
var ok=true;
if(window.localStorage){
this._storage=this.localStorage;
}else{
this._storage=this.userDataStorage;
this._storage.init();
ok=this._storage.isAvailable();
}
return ok;
},lastModToStr:function(obj){
return obj.timestamp+"\n"+obj.keys.join(",");
},pushLastModKey:function(key){
var lm=this.lastModify;
if(lm.length>20){
}else{
}
},getWriteSeq:function(){
return this.write_seq++;
},setLastMod:function(key,_71){
var o=this.getLastMod();
var _73=this.qLen;
var ts=new Date().getTime();
var lm=this.lastModify;
var _76={keys:o.keys.split(","),lastKeys:o.keys,timestamp:ts};
if(_76.keys.length>_73){
_76.keys.length=_73;
}
var pos=this.getWriteSeq()%_73;
_76.keys[pos]=key;
_76.lastKeys=_76.keys.join(",");
var _78=this.lastModToStr(_76);
this._storage.setItemTo("last"+pos,ts+" "+key,"webpager_control");
this._storage.setItemTo("lastMod",_78,"webpager_control",_71);
},clearLastMod:function(){
var ts=new Date().getTime();
var lm=this.lastModify;
lm.keys=[];
var _7b=this.lastModToStr(lm);
this._storage.setItemTo("lastMod",_7b,"webpager_control");
},setItemTo:function(key,_7d,_7e){
var _7f=this;
var _80=0;
try{
var ok=this._storage.setItemTo(key,_7d,_7e);
_80=1;
if(ok){
try{
this.setLastMod(_7e+"."+key);
}
catch(e){
ns.PersistMgr.reportExpt("cch13",e);
}
}
return ok;
}
catch(e){
var t=6+_80+"&exci=";
if(e.description){
t+=e.description;
}
if(e.number){
t+=e.number;
}
ns.PersistMgr.reportExpt("cch14",e);
return false;
}
},getItemFrom:function(key,_84){
var v=this._storage.getItemFrom(key,_84);
return v;
},clear:function(){
this._storage.clear();
},lock:function(){
this._storage.setItemTo("l",true,"webpager_control");
},unlock:function(){
this._storage.setItemTo("l",false,"webpager_control");
},isLock:function(){
return this._storage.getItemFrom("l","webpager_control")=="true";
},getStamp:function(){
return this.getItemFrom("timestamp","webpager_control");
},getLastMod:function(){
var obj={};
var lm=this.getItemFrom("lastMod","webpager_control");
if(!lm){
return {timestamp:new Date().getTime(),keys:"",keysAry:[]};
}
var ary=lm.split("\n");
if(ary){
obj.timestamp=ary[0];
obj.keys=ary[1];
obj.keysAry=ary[1]?ary[1].split(","):[];
}
return obj;
},getNewKeys:function(_89,_8a){
var tmp={};
var _8c={};
var ret=[];
if(_89.join("")==_8a.join("")){
return [_89[0]];
}
for(var i=0;i<_8a.length;i++){
if(tmp[_8a[i]]===undefined){
tmp[_8a[i]]=0;
}else{
tmp[_8a[i]]++;
}
}
for(i=0;i<_89.length;i++){
if(_8c[_89[i]]===undefined){
_8c[_89[i]]=0;
}else{
_8c[_89[i]]++;
}
}
var _8f;
for(var j=0;j<_89.length;j++){
_8f=_89[j];
if(tmp[_8f]===undefined||_8c[_8f]>tmp[_8f]){
if(!ns.isInArray(_8f,ret)){
ret.push(_8f);
}
}
}
return ret;
},getNewKeys2:function(_91,_92){
var ret=[];
var _94=[];
var tmp;
for(var i=0;i<this.qLen;i++){
tmp=this._storage.getItemFrom("last"+i,"webpager_control");
if(!tmp){
continue;
}
tmp=this.getLastObj(tmp);
if(tmp.timestamp>_91&&tmp.timestamp<=_92){
ret.push(tmp);
}
}
ret.sort(function(a,b){
return a.timestamp>b.timestamp;
});
for(var j=0;j<ret.length;j++){
_94.push(ret[j].key);
}
return _94;
},getLastObj:function(str){
var ary=str.split(" ");
return {timestamp:parseInt(ary[0]),key:ary[1]};
},storageMonit:function(){
var o=this.getLastMod();
if(this.timestamp!=o.timestamp){
var _9d=o.keys.split(",");
var aLk=this.lastModify.lastKeys.split(",");
var _9f=this.getNewKeys2(this.timestamp,o.timestamp);
var p={keys_raw:_9f.join(","),keys:ns.distinct(_9f).join(",")};
this.lastModify.lastKeys=o.keys;
this.lastModify.keys=_9d;
this.timestamp=o.timestamp;
this.fireEvent("storage",p);
}
var _a1=this;
this.monitTimer=setTimeout(function(){
_a1.storageMonit();
},this.MONIT_INTERV);
},getNid:function(m){
var nid=null;
if(m){
try{
var obj=eval("("+m.content+")");
if(obj&&obj.nid){
nid=obj.nid;
}
}
catch(e){
}
}
return nid;
},reportExpt:function(_a5,e){
this.report(_a5+"&e="+e);
},report:function(_a7,m){
try{
var _a9=["60.28.219.32","60.28.219.33"];
_a9=_a9[Math.floor(Math.random()*2)];
var id=ns.cookie.get("id");
var _ab="";
if(m&&m.touin){
_ab+=("&rid="+m.touin);
}
var url="http://"+_a9+"?ver=3&r="+Math.random()+_ab+"&uid="+id+"&step="+_a7;
var img=new Image();
img.src=url;
}
catch(e){
}
},localStorage:{setItemTo:function(key,_af,_b0){
try{
localStorage.setItem(_b0+"_"+key,_af);
}
catch(e){
ns.PersistMgr.reportExpt("cch01",e);
return false;
}
return true;
},getItemFrom:function(key,_b2){
return localStorage.getItem(_b2+"_"+key);
},removeItem:function(key){
localStorage.removeItem(key);
},clear:function(){
localStorage.clear();
},save:function(){
}},userDataStorage:{getItemFrom:function(key,_b5){
if(_b5=="webpager_control"){
return this.get(this.controlNode,_b5,key);
}else{
if(_b5=="webpager_msg"){
return this.get(this.hisNode,_b5,key);
}else{
return this.get(this.msgNode,_b5,key);
}
}
},setItemTo:function(key,_b7,_b8,_b9){
if(_b8=="webpager_control"){
return this.set(this.controlNode,_b8,key,_b7,_b9);
}else{
if(_b8=="webpager_msg"){
return this.set(this.hisNode,_b8,key,_b7,_b9);
}else{
return this.set(this.msgNode,_b8,key,_b7,_b9);
}
}
},removeItem:function(key){
this.msgNode.removeAttribute(key);
},clear:function(){
var d=this.msgNode.XMLDocument;
var _bc=d.selectSingleNode("ROOTSTUB");
for(var i=0;i<_bc.attributes.length;++i){
var a=_bc.attributes[i];
this.msgNode.removeAttribute(a.baseName);
}
this.msgNode.save("webpager_control");
},isAvailable:function(){
try{
this.msgNode.save();
}
catch(e){
if(e.number&&Math.abs(parseInt(e.number))==2146827838){
return true;
}
if(e.description&&(e.description.indexOf("Wrong number")!=-1||e.description.indexOf("\u9519\u8bef\u7684\u53c2\u6570\u4e2a\u6570")!=-1)){
ns.PersistMgr.reportExpt("cch03",e);
return true;
}
var t="10&info=";
if(e.description){
t+=e.description;
}
if(e.number){
t+=e.number;
}
return false;
}
},save:function(_c0){
this.msgNode.save(_c0);
},init:function(){
this.msgNode=this.createStorgeNode();
this.controlNode=this.createStorgeNode();
this.hisNode=this.createStorgeNode();
},createStorgeNode:function(){
var n=document.createElement("div");
n.style.display="none";
n.style.behavior="url(#default#userData)";
document.body.appendChild(n);
return n;
},set:function(_c2,_c3,key,_c5,_c6){
var t=key;
try{
_c2.setAttribute(key,_c5);
_c2.save(_c3);
if(_c6!==false){
_c2.save(_c3);
}
}
catch(e){
return false;
}
return true;
},get:function(_c8,_c9,key){
try{
_c8.load(_c9);
}
catch(e){
}
return _c8.getAttribute(key);
}},flashStorage:{getItemFrom:function(key,_cc){
return this.flash.getItem(_cc+"_"+key);
},setItemTo:function(key,_ce,_cf,_d0){
try{
this.flash.setItem(_cf+"_"+key,_ce);
}
catch(e){
ns.PersistMgr.reportExpt("cch04",e);
return false;
}
return true;
},removeItem:function(key){
try{
this.flash.removeItem(zone+"_"+key);
}
catch(e){
ns.PersistMgr.reportExpt("cch05",e);
return false;
}
return true;
},test:function(){
this.init();
},clear:function(){
},init:function(){
var _d2="webpager_flash_localStorage";
var url="http://wpi.renren.com/PObject.swf";
var _d4=document.createElement("embed");
_d4.setAttribute("id",_d2);
_d4.setAttribute("name",_d2);
_d4.setAttribute("type","application/x-shockwave-flash");
_d4.setAttribute("src",url);
_d4.setAttribute("width",1);
_d4.setAttribute("height",1);
_d4.setAttribute("style","position:absolute; right:0px; bottom:0px;");
document.body.appendChild(_d4);
this.flash=_d4;
}}};
ns.event.enableCustomEvent(ns.PersistMgr);
})(WPC);
(function(ns){
var ck=ns.cookie;
var xml=ns.xml;
var pf=ns.Profile;
ns.Comet={messageId:0,connErrCnt:0,connErrCntMax:5,errTryCnt:0,pollBackNum:0,errTryCntMax:5,connTimer:null,_xhrPoll:null,_xhrConn:null,connect:function(){
var _d9=this;
if(this._xhrConn){
this.connAbort();
this.abort();
}
this._xhrConn=new ns.net.ajax({url:"/comet_get?mid=0&r="+Math.random()+"&ins",onSuccess:function(){
_d9.connSucc();
},onError:function(){
_d9.connError();
}});
},testConnect:function(){
var _da=this;
this._xhrConn=new ns.net.ajax({url:"/comet_get?mid=0&r="+Math.random()+"&ins",onSuccess:function(){
_da.connSucc();
},onError:function(){
_da.connError();
}});
},abort:function(){
this.commonAbort=true;
this._xhrPoll&&this._xhrPoll.abort();
},connAbort:function(){
this._xhrConn&&this._xhrConn.abort();
},disconnect:function(){
this.abort();
return this.connState(0);
},connSucc:function(r){
this.connState(1);
this.errTryCnt=0;
this.connErrCnt=0;
this.doLongPoll();
this.fireEvent("comet_connected",r);
},connError:function(){
this.connState(0);
this._xhrConn=null;
++this.connErrCnt;
if(this.connErrCnt==this.connErrCntMax){
this.fireEvent("comet_connect_fail");
}else{
if(this.connErrCnt>this.connErrCntMax){
return;
}
}
},release:function(){
this._xhrPoll&&this._xhrPoll.abort();
this._xhrConn&&this._xhrConn.abort();
this._xhrPoll=null;
this._xhrConn=null;
},pollBack:function(r){
var _dd=this;
if(r.status==211){
this.release();
this.fireEvent("comet_release");
return;
}
this.errTryCnt=0;
var str=r.responseText;
try{
if(str){
var _a=ns.countStr(str,"type=\"notify2\"");
if(_a){
for(var i=0;i<_a;i++){
ns.PersistMgr.report("n"+81);
}
}
var _b=ns.countStr(str,"ugc_content");
if(_b){
for(var i=0;i<_b;i++){
ns.PersistMgr.report("n"+51);
}
}
}
}
catch(e){
}
try{
var o=xml.extractMessage(str);
if(o.length){
this.messageId=o[o.length-1].msg_id;
}
_dd.fireEvent("comet_got",o);
ns.PersistMgr.report(21);
}
catch(e){
ns.PersistMgr.report(71+"&e="+e);
}
this.doLongPoll();
},pollError:function(){
if(this.errTryCnt>=this.errTryCntMax){
this.connState(0);
this.fireEvent("comet_failed");
this._xhrPoll=null;
return;
}
this.errTryCnt++;
if(this.commonAbort){
this.commonAbort=false;
this.fireEvent("comet_disconnected");
this._xhrPoll=null;
return;
}
this.doLongPoll();
},doLongPoll:function(){
var _e3=this;
this._xhrPoll=new ns.net.ajax({url:"/comet_get?mid="+(this.messageId)+"&r="+Math.random(),onSuccess:function(r){
_e3.pollBack(r);
},onError:function(r){
_e3.pollError(r);
}});
},connState:function(_e6){
if(_e6!==undefined){
ck.set("wimconn",_e6);
return true;
}else{
var c=ck.get("wimconn");
return c!=null&&c!="0";
}
},send:function(str){
var _e9=this;
new ns.net.ajax({url:"/comet_broadcast",data:str,method:"post",onSuccess:function(r){
_e9.fireEvent("comet_send_succ");
}});
}};
var _eb=ns.Comet;
ns.event.enableCustomEvent(ns.Comet);
ns.CometMgr={id:0,CONN_CHECK_INTERV:2000,CONN_INTERV_CYCLE:60,autoReconnect:true,curCheckTime:0,aliveCycle:65,isLocalConn:false,lastConnState:0,init:function(){
this.bindEvent();
this.lastConnState=ns.Comet.connState();
this.connMonit();
},tryToConnect:function(){
if(!ns.getLoginUin()){
return;
}
var h=location.href;
var _ed=this;
if(!_eb.connState()&&ns.Profile.isUseIm()){
acquire("wimconn",function(){
_ed.isLocalConn=true;
_eb.connect();
if(_eb._xhrPoll){
}
},function(){
_eb.abort();
_ed.isLocalConn=false;
});
}
},retryConnect:function(){
this.isLocalConn=false;
_eb.disconnect();
this.tryToConnect();
},connMonit:function(){
if(_eb.isUnload){
clearTimeout(this.connTimer);
return;
}
var _ee=this;
var _ef=_eb.connState();
this.curCheckTime++;
if(_eb.lastConnState!=_ef){
if(0==_ef){
if(ns.Profile.isUseIm()){
this.tryToConnect();
}
this.fireEvent("cometmgr_disconnected");
}else{
this.fireEvent("cometmgr_connected");
}
}else{
if(this.autoReconnect&&this.isLocalConn&&this.curCheckTime==this.CONN_INTERV_CYCLE){
this.curCheckTime=0;
this.retryConnect();
this.fireEvent("monit_cycle");
}
if(!this.isAlive()){
this.isLocalConn=false;
_eb.disconnect();
this.tryToConnect();
}else{
if(this.isLocalConn&&!this.isMyConn()){
this.isLocalConn=false;
_eb.release();
}
}
}
_eb.lastConnState=_ef;
this.connTimer=setTimeout(function(){
clearTimeout(_ee.connTimer);
_ee.connMonit();
},this.CONN_CHECK_INTERV);
},getConnState:function(){
var _f0=_eb.connState();
return _f0;
},bindEvent:function(){
var _f1=this;
_eb.addEvent("comet_connected",function(){
if(_f1.isLocalConn){
_f1.keepAlive();
_f1.autoReconnect=true;
}
_f1.fireEvent("cometmgr_connected");
});
_eb.addEvent("comet_release",function(){
_f1.isLocalConn=false;
});
_eb.addEvent("comet_connect_fail",function(){
_f1.isLocalConn=false;
});
_eb.addEvent("comet_got",function(m){
_f1.fireEvent("comet_got",m);
});
_eb.addEvent("comet_failed",function(){
_f1.isLocalConn=false;
_f1.autoReconnect=false;
_f1.fireEvent("comet_disconnected");
});
_eb.addEvent("comet_send_succ",function(){
_f1.fireEvent("cometmgr_send_succ");
});
window.onbeforeunload=function(){
WPC.Comet.isUnload=true;
if(_f1.isLocalConn){
_eb.disconnect();
}
};
window.onunload=function(){
WPC.Comet.isUnload=true;
if(_f1.isLocalConn){
_eb.disconnect();
}
};
},send:function(_f3,_f4){
_eb.send(this.buildMessage(_f3,_f4));
},buildMessage:function(_f5,_f6){
assert(_f5.length>0);
var p={fromserver:"@talk.renren.com"};
switch(_f6){
case "groupchat":
p.toserver="@group.talk.renren.com";
p.type="groupchat";
break;
default:
p.toserver="@talk.renren.com";
p.type="chat";
break;
}
var xml=["<sendlist>\n"];
for(var i=0;i<_f5.length;++i){
var m=_f5[i];
xml.push("<message type=\""+p.type+"\" from=\"");
xml.push(m.from+p.fromserver);
xml.push("\"");
xml.push(" to=\"");
xml.push(m.to+p.toserver);
xml.push("\">\n<body>");
xml.push(ns.xmlEncode(m.msg_content));
xml.push("</body>\n</message>\n");
}
xml.push("</sendlist>\n\x00");
return xml.join("");
},keepAlive:function(){
this.curCheckTime=0;
this.id=new Date().getTime();
ck.set("wkl",this.id);
},isAlive:function(){
var t=ck.get("wkl");
t=parseInt(t);
tNow=new Date().getTime();
if(isNaN(t)){
return false;
}
if(tNow-t<this.aliveCycle*this.CONN_CHECK_INTERV){
return true;
}else{
return false;
}
},isMyConn:function(){
var t=ck.get("wkl");
t=parseInt(t);
return t=this.id;
},connect:function(){
this.isLocalConn=true;
_eb.connect();
},disconnect:function(){
_eb.disconnect();
}};
ns.event.enableCustomEvent(ns.CometMgr);
})(WPC);
(function(ns){
var pm=ns.PersistMgr;
var cm=ns.CometMgr;
var ck=ns.cookie;
ns.MsgMgr={MSG_HISRY_COUNT:32,SEQ_EXPIRE_DAYS:10*365,msg_list:[],zone:{2:"webpager_msg",3:"webpager_notify"},init:function(){
this.bindEvent();
},bindEvent:function(){
var This=this;
var cm=ns.CometMgr;
cm.addEvent("comet_got",function(m){
var _104=0;
var _105="";
var len=m.length;
for(var i=0;i<len;i++){
var ret=m[i];
if(!ret){
continue;
}
var _109=ret.content;
var obj=ns.json.parse(_109);
if(ret.content&&ret.content.indexOf("{\"show\":\"hidden\"")!=-1){
continue;
}
if(ret.touin&&obj&&(ret.touin-0)==(obj.from_id-0)){
_104++;
try{
_105+=(ns.PersistMgr.getNid(m[i])+",");
}
catch(e){
}
continue;
}
switch(ret.type){
case "chat":
ns.PersistMgr.report(61);
This.addMsgHistory(ret);
break;
case "notify2":
ns.PersistMgr.report(81,m[0]);
try{
if(m&&m[i]&&m[i].content&&(m[i].content.indexOf("ugc_content")!=-1)){
_104++;
try{
_105+=(ns.PersistMgr.getNid(m[i])+",");
}
catch(e){
}
}
}
catch(e){
}
This.addRealTime(ret);
break;
case "groupchat":
if(ret.from.indexOf("-"+ns.getLoginUin())!=-1){
return;
}
This.addGroupChat(ret,len);
break;
default:
This.addOtherMsg(ret);
break;
}
}
if(_104){
try{
ns.PersistMgr.report(51+"&nids="+_105+"&count="+_104,m[0]);
}
catch(e){
}
}
});
cm.addEvent("cometmgr_send_succ",function(){
This.msg_list.length=0;
});
pm.addEvent("storage",function(e){
var keys=e.keys.split(","),key;
var temp,zone;
for(var i=0;i<keys.length;i++){
key=keys[i];
temp=key.split(".");
zone=temp[0];
key=temp[1];
if(zone!="webpager_msgs"){
continue;
}
var _111=pm.getItemFrom(key,"webpager_msgs");
var type;
type=This.getMsgType(_111);
if(type=="group"){
This.fireEvent("groupmsg_got",This.strToGroupChat(pm.getItemFrom(key,zone)));
}else{
if(type=="notify2"){
This.fireEvent("realTime_got",This.strToRealTime(pm.getItemFrom(key,zone)));
}else{
if(type=="chat"){
var val=pm.getItemFrom(key,zone);
var obj=This.strToMsg(val);
This.fireEvent("message_got",obj);
}else{
This.fireEvent("other_got",This.str2other(pm.getItemFrom(key,zone)));
}
}
}
}
});
},getMsgType:function(str){
var ary=str.split("\n");
return ary[0];
},getMsgSeq:function(m){
var n=parseInt(ck.get(m||"wimmseq"));
if(isNaN(n)){
return -1;
}
return n>=0?n:0;
},setMsgSeq:function(seq,m){
ck.set(m||"wimmseq",seq,this.SEQ_EXPIRE_DAYS);
},send:function(m,type){
var p={from:m.fromuin,fname:m.fromname,to:m.touin,msg_content:m.msg_content};
if(type===undefined||type=="chat"){
this.addMsgHistory(p);
}
cm.send([p],type);
},loadMsgHistory:function(uid){
uid=uid+"";
var cnt=this.MSG_HISRY_COUNT;
var ret=[],m;
var _122=ns.getLoginUin();
for(var i=0;i<cnt;i++){
m=pm.getItemFrom("m"+i,"webpager_msg");
m=this.strToMsg(m);
if(!m.timestamp){
m.timestamp=new Date().getTime();
}
if(m.fromuin==uid&&m.touin==_122||m.fromuin==_122&&m.touin==uid){
ret.push(m);
}
}
if(ret.length){
ret.sort(function(a,b){
var aa=parseInt(a.timestamp);
var bb=parseInt(b.timestamp);
if(aa<bb){
return 1;
}
if(aa>bb){
return -1;
}
return 0;
});
}
return ret;
},msgToStr:function(obj){
return "chat\n"+obj.fromuin+"\n"+obj.fromname+"\n"+obj.touin+"\n"+obj.msg_content+"\n"+obj.timestamp;
},strToMsg:function(str){
var obj={};
if(!str){
return obj;
}
var ary=str.split("\n");
if(!ary){
return obj;
}
obj.fromuin=ary[1];
obj.fromname=ary[2];
obj.touin=ary[3];
obj.msg_content=ary[4];
obj.timestamp=ary[5];
return obj;
},addMsgHistory:function(m){
try{
var p={fromuin:parseInt(m.from),fromname:m.fname,touin:parseInt(m.to),msg_content:m.msg_content,timestamp:new Date().getTime()};
var s_m=this.msgToStr(p);
var seq=ns.seqq.getNextSeq();
pm.setItemTo(seq,s_m,"webpager_msgs");
var _130=this.getMsgSeq()+1;
pm.setItemTo("m"+(_130%this.MSG_HISRY_COUNT),s_m,"webpager_msg");
this.setMsgSeq(_130);
}
catch(e){
ns.PersistMgr.reportExpt("cch06",e);
}
},addNotifyHistory:function(n){
},strToRealTime:function(str){
var obj={};
if(!str){
return obj;
}
var ary=str.split("\n");
if(!ary){
return obj;
}
obj.type=ary[0];
obj.touin=ary[1];
obj.msg_id=ary[2];
obj.content=ary[3];
return obj;
},realTimeToStr:function(r){
return r.type+"\n"+r.touin+"\n"+r.msg_id+"\n"+r.content;
},groupChatToStr:function(r){
return "group\n"+r.from+"\n"+r.to+"\n"+r.msg_id+"\n"+r.content;
},strToGroupChat:function(str){
var obj={};
if(!str){
return obj;
}
var ary=str.split("\n");
if(!ary){
return obj;
}
obj.mtype=ary[0];
obj.mfrom=ary[1];
obj.mto=ary[2];
obj.msg_id=ary[3];
obj.content=ary[4];
return obj;
},str2other:function(str){
var obj={};
if(!str){
return obj;
}
var ary=str.split("\n");
if(!ary){
return obj;
}
obj.mtype=ary[0];
obj.from=ary[1];
obj.touin=ary[2];
obj.msg_id=ary[3];
obj.content=ary[4];
return obj;
},other2str:function(o){
return o.type+"\n"+o.from+"\n"+o.to+"\n"+o.msg_id+"\n"+o.content;
},addOtherMsg:function(o){
var s_o=this.other2str(o);
var seq=ns.seqq.getNextSeq();
pm.setItemTo(seq,s_o,"webpager_msgs");
},addRealTime:function(r){
var s_r=this.realTimeToStr(r);
var seq=ns.seqq.getNextSeq();
pm.setItemTo(seq,s_r,"webpager_msgs");
},addGroupChat:function(r,len){
var s_r=this.groupChatToStr(r);
var seq=ns.seqq.getNextSeq();
pm.setItemTo(seq,s_r,"webpager_msgs");
}};
ns.event.enableCustomEvent(ns.MsgMgr);
})(WPC);
(function(ns){
var cm=ns.CometMgr;
var sd=ns.Sound;
var pf=ns.Profile;
var mm=ns.MsgMgr;
var pm=ns.PersistMgr;
var ck=ns.cookie;
ns.PagerChannel={init:function(){
this.bindEvent();
},bindEvent:function(){
var This=this;
pf.addEvent("profile_useIM_switch",function(b){
if(b=="1"){
ns.CometMgr.connect();
}else{
ns.CometMgr.disconnect(true);
}
});
mm.addEvent("message_got",function(m){
This.fireEvent("message_got",m);
});
mm.addEvent("realTime_got",function(r){
r.timestamp=new Date().getTime();
r.type=56;
This.fireEvent("realTime_got",r);
});
mm.addEvent("groupmsg_got",function(gc){
This.fireEvent("groupmsg_got",gc);
});
mm.addEvent("other_got",function(_154){
This.fireEvent("other_got",_154);
});
cm.addEvent("cometmgr_connected",function(){
try{
top.$msg_proxy&&top.$msg_proxy.onConnected();
}
catch(e){
ns.PersistMgr.reportExpt("cch07",e);
}
});
cm.addEvent("cometmgr_disconnected",function(){
try{
top.$msg_proxy&&top.$msg_proxy.onDisconnected();
This.fireEvent("channel_disconnected");
}
catch(e){
ns.PersistMgr.reportExpt("cch08",e);
}
});
pm.addEvent("storage",function(e){
This.fireEvent("storage",e);
});
},startIM:function(){
var _156=(document.domain.indexOf("renren.com")!=-1);
var xn=top.XN;
var g=top.XN.cookie.get;
var ret,_t,res;
if(g("id")&&g("t")&&g("xnsid")&&_156&&xn.browser.IE){
try{
var svr=new ActiveXObject("renren.Renren.1");
if(svr){
top.webpager.IMInstalled=true;
}
var res=svr.IfNeedStart("xntalk");
if(res==true){
_t=svr.StartUp("xntalk");
if(_t==false){
ret=ns.startXnclient();
}else{
ret=true;
}
}else{
ret=false;
}
}
catch(e){
ret=ns.startXnclient();
}
}
top.webpager.fireEvent("im_start_over",ret);
},iamReady:function(wpUI){
wpUI.showNotice=true;
},sendMessage:function(e,type){
mm.send(e,type);
},getMessageHistory:function(uid){
var a=mm.loadMsgHistory(uid);
return a;
},getNotifyHistory:function(){
return [];
},enableConn:function(b){
if(b){
pf.setUseIm(true,true);
}else{
pf.setUseIm(false,true);
}
},isLocalConnect:function(){
return cm.isLocalConn;
},showRealTime:function(_163){
mm.addRealTime({content:_163,type:"notify2",touin:ns.getLoginUin(),msg_id:mm.messageId});
},setItem:function(key,_165,_166){
setTimeout(function(){
return pm.setItemTo(key,_165,"webpager_common"+(_166?"":ns.getLoginUin()));
},0);
},getItem:function(key,_168){
return pm.getItemFrom(key,"webpager_common"+(_168?"":ns.getLoginUin()));
},showGroupChat:function(m){
mm.addGroupChat({from:m.from,to:m.to,msg_id:0,content:m.content});
},getConnState:function(){
return cm.getConnState();
},setPlaySound:function(b){
return pf.setPlaySound(b,true);
},getShowPager:function(){
return true;
},notificationRequest:function(_16b){
window.webkitNotifications.requestPermission(function(){
var p=window.webkitNotifications.checkPermission();
_16b(p);
});
},notificationShow:function(obj){
if(!window.webkitNotifications.checkPermission()){
var ntc;
ntc=window.webkitNotifications.createNotification(obj.head,obj.name,obj.content);
ntc.show();
ntc.onclick=function(){
window.focus();
};
setTimeout(function(){
ntc.cancel();
},8000);
}
},notificationPermission:function(){
return window.webkitNotifications.checkPermission();
}};
ns.event.enableCustomEvent(ns.PagerChannel);
document.domain="renren.com";
top.webpager=WPC.PagerChannel;
})(WPC);
var imHelper={getCookie:function(key){
return WPC.cookie.get(key);
},setCookie:function(key,_171,_172){
WPC.cookie.set(key,_171,_172);
},playSound:function(){
WPC.sound.playSound();
}};
var wpcontroller={onInputMessage:function(msg){
WPC.MsgMgr.send(msg);
},getMessageHistory:function(uid){
WPC.MsgMgr.loadMsgHistory(uid);
}};
(function(ns){
function pagerChannelIsOk(XN,_177){
if(!XN.disableWebpager){
try{
var _178=XN.getFileVersionNum("http://s.xnimg.cn/jspro/xn.app.webpager.js").version;
_178=parseInt(_178.substring(1));
}
catch(e){
var _178=0;
}
var _179=_177.wpVersion;
_179=parseInt(_179.substring(1));
if(_179>_178){
XN.loadFile("http://s.xnimg.cn/"+_177.wpVersion+"/jspro/xn.app.webpager.js");
}else{
XN.loadFile("http://s.xnimg.cn/jspro/xn.app.webpager.js");
}
}
}
top.webpager&&top.webpager.addEvent("im_start_over",function(_17a){
top.webpager.storageOk=ns.PersistMgr.init();
top.webpager.imRunning=_17a;
ns.CometMgr.init();
ns.MsgMgr.init();
ns.PagerChannel.init();
if(document.domain.indexOf("renren.com")!=-1){
document.domain="renren.com";
}else{
if(document.domain.indexOf("kaixin.com")!=-1){
document.domain="kaixin.com";
}
}
var _17b=window.uiVer||"a21208";
if(top.webpagerLoader){
top.webpagerLoader.fireEvent("channel_ok",_17b);
}
if(top&&top.XN){
ns.PersistMgr.report("b0");
pagerChannelIsOk(top.XN,{wpVersion:_17b});
}
});
top.webpager.startIM();
})(WPC);
